package com.bawei.mdm2207alast.model.db

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
 * 作者：赵亮
 * 时间：2024/12/23 15:59
 * 功能：数据访问模块
 */
@Module
@InstallIn(SingletonComponent::class)
object DataModule {

    @Provides
    @Singleton
    fun initDataBase(@ApplicationContext context: Context): AppDataBase {
        return AppDataBase.init(context)
    }

    @Provides
    fun getUserDao(appDataBase: AppDataBase): UserDao {
        return appDataBase.userDao()
    }

    @Provides
    fun getAskDao(appDataBase: AppDataBase):AskDao {
        return appDataBase.askDao()
    }
}